package com.learn.project2.controller.wx.collect;

import com.learn.project2.model.bo.wx.collect.CollectAddOrDeleteBO2;
import com.learn.project2.model.bo.wx.collect.CollectListBO2;
import com.learn.project2.model.vo.collect.CollectListVO2;
import com.learn.project2.service.wx.collect.CollectService2;
import com.learn.project2.utils.Result;
import org.apache.shiro.SecurityUtils;
import org.apache.shiro.subject.Subject;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

/**
 * @description:  收藏
 * @author 亓永杰
 * @date 2022-01-09 23:08
 * @version 1.0
 */
@RestController
@RequestMapping("wx/collect")
public class CollectController2 {

    @Autowired
    CollectService2 collectService2;

    @RequestMapping("list")
    public Result list(CollectListBO2 collectListBO2){
        CollectListVO2 collectListVO2 = collectService2.collectList(collectListBO2);
        return Result.ok(collectListVO2);
    }

    @RequestMapping("addordelete")
    public Result addOrDelete(@RequestBody CollectAddOrDeleteBO2 collectAddOrDeleteBO2){
        Subject subject = SecurityUtils.getSubject();
        Object principal = subject.getPrincipal();
        if (principal==null){
            return Result.fail2("请登录！");
        }
        collectService2.collectAddOrDelete(collectAddOrDeleteBO2);
        return Result.ok();
    }

}
